package com.example.demo;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MySchedule {
    /*@Scheduled(fixedDelay = 3000)
    public void foo() {
        System.out.println("fixedDelay:" + new Date());
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }*/
   /* @Scheduled(fixedRate = 3000)
    public void foo() {
        System.out.println("fixedRate:" + new Date());
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }*/
   // 秒、分、时、天、月、星期
//    @Scheduled(cron = "0 * * * * ?")
    public void foo() {
        System.out.println("cron:" + new Date());
    }
}
